/*
 * Copyright © 2004-2014 chenYuan. All rights reserved.
 * @Website:wwww.jspx.net
 * @Mail:39793751@qq.com
 * @author: chenYuan , 陈原
 * @License: Jspx.net Framework Code is open source (LGPL)，Jspx.net Framework 使用LGPL 开源授权协议发布。
 * @jvm:jdk1.6+  x86/amd64
 *
 */
package com.jspx.util;


import java.util.LinkedHashMap;

public class LRUHashMap<K, V> extends LinkedHashMap<K, V> {
    private int maxCapacity;

    public LRUHashMap(int maxCapacity) {
        this.maxCapacity = maxCapacity;
    }

    public void setMaxCapacity(int maxCapacity) {
        this.maxCapacity = maxCapacity;
    }

    @Override
    public V put(K key, V value) {
        if (super.size() < maxCapacity) {
            return super.put(key, value);
        }
        return null;
    }

}